Telegram Group & Telegram Channel
Разница между генераторными выражениями и генераторами коллекций

Записи в первой и второй строчке в коде выше очень похожи, но различаются видами скобок. В генераторе списка они квадратные, а в генераторном выражении – круглые.

Распечатав переменные, можно заметить, что значением переменной a является список, а переменная x хранит в себе объект генератора. И здесь возникает вопрос, что же использовать.

Если вам нужен результат, например в виде списка, прямо сейчас для дальнейшего выполнения программы, то используйте генераторы коллекций.

А если же значения понадобятся еще не скоро или вообще неизвестно, понадобится ли они вообще, то предпочтительнее генераторы, чтобы не занимать лишнюю память и не нагружать систему.

#генераторы



tg-me.com/python_academy/340
Create:
Last Update:

Разница между генераторными выражениями и генераторами коллекций

Записи в первой и второй строчке в коде выше очень похожи, но различаются видами скобок. В генераторе списка они квадратные, а в генераторном выражении – круглые.

Распечатав переменные, можно заметить, что значением переменной a является список, а переменная x хранит в себе объект генератора. И здесь возникает вопрос, что же использовать.

Если вам нужен результат, например в виде списка, прямо сейчас для дальнейшего выполнения программы, то используйте генераторы коллекций.

А если же значения понадобятся еще не скоро или вообще неизвестно, понадобится ли они вообще, то предпочтительнее генераторы, чтобы не занимать лишнюю память и не нагружать систему.

#генераторы

BY Python Academy




Share with your friend now:
tg-me.com/python_academy/340

View MORE
Open in Telegram


Python Academy Telegram | DID YOU KNOW?

Date: |

How Does Bitcoin Work?

Bitcoin is built on a distributed digital record called a blockchain. As the name implies, blockchain is a linked body of data, made up of units called blocks that contain information about each and every transaction, including date and time, total value, buyer and seller, and a unique identifying code for each exchange. Entries are strung together in chronological order, creating a digital chain of blocks. “Once a block is added to the blockchain, it becomes accessible to anyone who wishes to view it, acting as a public ledger of cryptocurrency transactions,” says Stacey Harris, consultant for Pelicoin, a network of cryptocurrency ATMs. Blockchain is decentralized, which means it’s not controlled by any one organization. “It’s like a Google Doc that anyone can work on,” says Buchi Okoro, CEO and co-founder of African cryptocurrency exchange Quidax. “Nobody owns it, but anyone who has a link can contribute to it. And as different people update it, your copy also gets updated.”

What Is Bitcoin?

Bitcoin is a decentralized digital currency that you can buy, sell and exchange directly, without an intermediary like a bank. Bitcoin’s creator, Satoshi Nakamoto, originally described the need for “an electronic payment system based on cryptographic proof instead of trust.” Each and every Bitcoin transaction that’s ever been made exists on a public ledger accessible to everyone, making transactions hard to reverse and difficult to fake. That’s by design: Core to their decentralized nature, Bitcoins aren’t backed by the government or any issuing institution, and there’s nothing to guarantee their value besides the proof baked in the heart of the system. “The reason why it’s worth money is simply because we, as people, decided it has value—same as gold,” says Anton Mozgovoy, co-founder & CEO of digital financial service company Holyheld.

Python Academy from no


Telegram Python Academy
FROM USA